home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / bisonpcb / getargs.c < prev    next >
C/C++ Source or Header  |  1987-02-12  |  2KB  |  100 lines

  1. /* Parse command line arguments for bison,
  2.    Copyright (C) 1984, 1986 Bob Corbett and Free Software Foundation, Inc.
  3.   
  4. BISON is distributed in the hope that it will be useful, but WITHOUT ANY
  5. WARRANTY.  No author or distributor accepts responsibility to anyone
  6. for the consequences of using it or for whether it serves any
  7. particular purpose or works at all, unless he says so in writing.
  8. Refer to the BISON General Public License for full details.
  9.   
  10. Everyone is granted permission to copy, modify and redistribute BISON,
  11. but only under the conditions described in the BISON General Public
  12. License.  A copy of this license is supposed to have been given to you
  13. along with BISON so you can know your rights and responsibilities.  It
  14. should be in a file named COPYING.  Among other things, the copyright
  15. notice and this notice must be preserved on all copies.
  16.   
  17.  In other words, you are welcome to use, share and improve this program.
  18.  You are forbidden to forbid anyone else to use, share and improve
  19.  what you give them.   Help stamp out software-hoarding!  */
  20.  
  21. /*
  22.  * Port to PC by Whit Gregg
  23.  *               Nourse, Gregg & Browne, Inc.
  24.  *         1 Horizon Road
  25.  *         Fort Lee, NJ  07024
  26.  */
  27.  
  28.  
  29. #include <stdio.h>
  30. #include "files.h"
  31. #include "func.h"
  32.  
  33.     int verboseflag;
  34. int definesflag;
  35. extern int fixed_outfiles;    /* JF */
  36.  
  37.  
  38. void 
  39. getargs(argc, argv)        /* WG */
  40.     int argc;
  41.     char *argv[];
  42.  
  43. {
  44.     register int i;
  45.     register char *cp;
  46.     register int duplicates;
  47.  
  48.     verboseflag = 0;
  49.     definesflag = 0;
  50.     duplicates = 0;
  51.  
  52.     i = 1;
  53.     while (i < argc && *argv[i] == '-') {
  54.         cp = argv[i] + 1;
  55.         while (*cp) {
  56.             switch (*cp) {
  57.                 case 'y':    /* JF this case */
  58.                 case 'Y':
  59.                 if (fixed_outfiles)
  60.                     duplicates = 1;
  61.                 else
  62.                     fixed_outfiles = 1;
  63.                 break;
  64.  
  65.                 case 'v':
  66.                 case 'V':
  67.                 if (verboseflag)
  68.                     duplicates = 1;
  69.                 else
  70.                     verboseflag = 1;
  71.                 break;
  72.  
  73.                 case 'd':
  74.                 case 'D':
  75.                 if (definesflag)
  76.                     duplicates = 1;
  77.                 else
  78.                     definesflag = 1;
  79.                 break;
  80.  
  81.                 default:
  82.                 fatals("illegal option:  %s", argv[i]);
  83.                 }
  84.             cp++;
  85.             }
  86.         i++;
  87.         }
  88.  
  89.     if (duplicates)
  90.         fprintf(stderr, "warning: repeated arguments ignored");
  91.  
  92.     if (i == argc)
  93.         fatal("grammar file not specified");
  94.     else
  95.         infile = argv[i];
  96.  
  97.     if (i < argc - 1)
  98.         fprintf(stderr, "warning: extra arguments ignored");
  99.     }
  100.